package com.wisezone;

import java.io.*;

public class Test {
    public static void main(String[] args) {
        String path="test";
        File file = new File (path);
        if (!file.exists()){
            file.mkdir();
        }

        //要复制的文件路径：
        String pathFile="E:\\job\\homework\\src\\com\\wisezone\\Test.java";
        //目标文件
        String targetPath="test\\Test.java";

        FileInputStream fis=null;
        FileOutputStream fileOutputStream=null;
        try {
            File srcfile = new File(pathFile);
            //读取要复制的文件内容
            fis = new FileInputStream(pathFile);
            long len=srcfile.length();
            byte[] b = new byte[(int)len];
            fis.read(b);

            //把读出来的字节数组写入文件
            File targetFile = new File(targetPath);
            FileOutputStream fileOutpuStream=new FileOutputStream(targetFile);
            fileOutpuStream.write(b);
            fileOutpuStream.flush();
        }catch (FileNotFoundException e){
            e.printStackTrace();
        }catch (IOException e){
            e.printStackTrace();
        }finally {
            try{
                fis.close();
            }catch (IOException e){
                e.printStackTrace();
            }

        }
    }
}
